package com.sit.controller;

import com.sit.service.LoginService;
import com.sit.vo.LoginVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;




@Controller
public class LoginController {
    @Autowired
    private LoginService loginService;

    @ResponseBody
    @RequestMapping("/login")
    public LoginVO login(@RequestParam("ano") String ano, @RequestParam("password") String password, @RequestParam("role") int role) {
        System.out.println(role);
        LoginVO loginVO = new LoginVO();
        System.out.println(ano);
        if (role== 1){
            if (loginService.checkAthlete(ano, password)==1){
                loginVO.setMsg("success");
                System.out.println(123);
            }else {
                loginVO.setMsg("error");

            }
        }else if(role==0){
            if (loginService.checkAdmin(ano, password)==1){
                loginVO.setMsg("successAdmin");
            }else {
                loginVO.setMsg("error");
            }
        }
        return loginVO;
    }

}
